package com.llc.mall.user.domain.user.entity;

import com.alibaba.cloud.commons.lang.StringUtils;
import com.llc.mall.user.domain.user.objectvalue.UserProfile;
import lombok.Builder;
import lombok.Getter;

@Getter
@Builder
public class User {
    private Long id;
    private Long accountId;
    private String userName;
    private String password;
    private String nickName;
    private String pic;
    private Integer status;

    public void register() {
        this.status = 1;
        if (nickName == null || nickName.trim().isBlank()) {
            this.nickName = userName;
        }
    }

    public void modify(UserProfile userProfile) {
        if (StringUtils.isNotBlank(userProfile.nickName())) {
            this.nickName = userProfile.nickName();
        }
        if (StringUtils.isNotBlank(userProfile.pic())) {
            this.pic = userProfile.pic();
        }
    }
}
